<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
    <style>
        img{
            background-color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <!--可通过fit确定图片如何适应到容器框，同原生 object-fit。
    fill 填充(完整显示图片,并且充满容器框,但不保证宽高比)
    contain (完整显示图片,并且保证宽高比,但不保证充满容器框)
    cover (不完整显示图片,保证宽高比,充满容器框)
    none (随机显示一个图片的部分,不推荐)
    scale-down (作用和contain类似)-->
    <div class="demo-image">
        <div class="block" v-for="fit in fits" :key="fit">
            <span class="demonstration">{{ fit }}</span>
            <el-image
                    style="width: 100px; height: 100px"
                    :src="url"
                    :fit="fit"></el-image>
        </div>
        <!--所有图片尺寸为200*200-->
        <h1>1. 保证图片完整显示并且不能变形</h1>
        <el-image style="width: 200px;height: 200px;"
         :src="url" fit="contain"></el-image>
        <h1>2. 保证图片完整显示</h1>
        <el-image style="width: 200px;height: 200px;"
                  :src="url" fit="fill"></el-image>
        <h1>3. 保证图片宽高比并且占满200*200</h1>
        <el-image style="width: 200px;height: 200px;"
                  :src="url" fit="cover"
                  :preview-src-list="srcList"></el-image>
        <!--可通过 previewSrcList 开启预览大图的功能。-->
        <!--可通过lazy开启懒加载功能，当图片滚动到可视范围内才会加载。
        可通过scroll-container来设置滚动容器，若未定义，则为最近一个
        overflow值为auto或scroll的父元素。-->

        <div scroll-container>
        <div class="demo-image__lazy" >
            <el-image v-for="url in urls" :key="url" :src="url" lazy></el-image>
        </div>
        </div>
    </div>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script>
    let v=new Vue({
        el: '#app',
        data: function() {
            return {
                fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
                url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
                srcList: [
                    'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
                    'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
                ],
                urls: [
                    'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
                    'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
                    'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
                    'https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg',
                    'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg',
                    'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
                    'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg'
                ],
            }
        }
    })
</script>
</html>